package master2;

import java.util.Scanner;

/**
 * @author chenyw
 * @date 2022/9/25 11:21
 * 丢失的数字
 */
public class M268missingNumber {
    //异或，丢失的数只出现了一次
    public static int missingNumber(int[] nums) {
        int res = 0;
        res ^= nums.length;
        for (int i = 0; i < nums.length; i++) {
            res ^= nums[i];
            res ^= i;
        }
        return res;

    }
}
